<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据库 - mysqli</title>
</head>

<body>
    <?php
    $servername = "43.139.70.207";
    $username = "egg";
    $password = "123456";
    $dbname = "egg";

    // 创建连接
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) { //->操作对象属性
        die("连接失败: " . $conn->connect_error);
    }

    $sql = "SELECT id, name, phone FROM user"; //查询语句
    $result = $conn->query($sql); //执行查询

    if ($result->num_rows > 0) {
        // 输出数据
        while ($row = $result->fetch_assoc()) {
            echo "id: " . $row["id"] . " - Name: " . $row["name"] . " " . $row["phone"] . "<br>";
        }
    } else {
        echo "0 结果";
    }
    $conn->close(); //关闭连接
    ?>

    <a href="https://www.runoob.com/php/php-mysql-connect.html" target="_blank">更多操作</a>

</body>

</html>